//package com.fll.fangyigateway.controller;
//
//import com.fll.fangyigateway.loadblance.RoundLoadBalance;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.client.ServiceInstance;
//import org.springframework.cloud.client.discovery.DiscoveryClient;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
///**
// * @author fll
// * create 2023/2/26
// */
//import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
//@RestController
//@Slf4j
//public class TestController {
//
//
//    @Autowired
//    private DiscoveryClient discoveryClient;
//
////    @Autowired
////    private RestTemplate restTemplate;
//
//    @Autowired
//    private RoundLoadBalance roundLoadBalance;
//
//
//    @Autowired
//    private LoadBalancerClient loadBalancerClient;
//
//    @RequestMapping("/test")
//    public String orderToMember() {
//        // HttpClient 工具类 实现RPC远程调用
//        // String memberUrl = "http://localhost:8080/getMember";
//        /**
//         * 根据服务名称 从注册中心 获取 会员的接口地址
//         * 服务提供 启动多个集群
//         *
//         */
////        List<ServiceInstance> instances = discoveryClient.getInstances("mumber-producer");
////        ServiceInstance serviceInstance = instances.get(0);
//
//        //轮询算法
//        ServiceInstance choose = roundLoadBalance.getInstances("fangyi-user");
//
//
//        // 会员服务的ip和端口
//        //采用负载均衡，默认采用轮询机制
////        ServiceInstance choose = loadBalancerClient.choose("fangyi-user");
//        String memberUrl = "http://" + choose.getHost() + ":" + choose.getPort() + "/" + "test";
//        return memberUrl;
//    }
//
//
//}
